# https://g1879.gitee.io/drissionpagedocs/WebPage/intro
import json
from operator import index
from DrissionPage import WebPage


from DrissionPage import ChromiumOptions

import os 
os.environ["DISPLAY"] = "localhost:10"

print(os.environ)
# 设置参数 https://g1879.gitee.io/drissionpagedocs/ChromiumPage/create_page_obj/
path = "/usr/bin/google-chrome-stable"

# https://g1879.gitee.io/drissionpagedocs/QandA
co = (
    ChromiumOptions(ini_path="./dp_configs.ini")
    .set_browser_path(path)
    # .set_argument("--no-sandbox --hide-crash-restore-bubble")
    .set_argument("--no-sandbox")
    .set_pref("credentials_enable_service", False)
 
)
# 默认d模式创建对象
page = WebPage(chromium_options=co)

# 模式
print(page.mode)


# 跟监听器配合，可在获取到需要的数据包时，主动停止加载。
page.set.load_mode.none()  # 设置加载模式为none


page.get('https://club.magedu.com/answers/7e7e7f7ff7g59gc2')

# textarea = page('css:.comment-editor')('css:.comment-editor__input.ivu-input-wrapper.ivu-input-wrapper-default.ivu-input-type')('t:textarea')
# print(textarea,'---')
# # textarea.focus()
# textarea.input('adfasdfasdf',clear=False)


page.wait.ele_loaded("t:textarea")    
page.wait.ele_loaded("tx:提交回答")    
textarea = page.ele("t:textarea")
button = page.ele("tx:提交回答")
print(button)
